﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 例2._2_反序数_CSharp
{
    class Program
    {
		
		static void Main(string[] Args)
		{
			for (int i = 1000; i <= 10000 / 9; i++)
			{
				Program program = new Program();
				int reverse = program.Reverse(i);
				//int reverse = i / 1000 + i % 1000 / 100 * 10 + i % 100 / 10 * 100 + i % 10 * 1000;
				if (reverse == 9 * i)
				{
                    Console.WriteLine(i);
				}
			}
			Console.ReadKey();
		}

		//或者另一种求反序数比较优雅的方式，但是时间花费可能更多
		int Reverse(int num)
		{
			int revx = 0;
			while (num != 0)
			{
				int midNum = num % 10;
				num = num / 10;
				revx = revx * 10 + midNum;
			}
			return revx;
		}
	}
}
